--CREATING THE MAIN TABLE WITH FLIGHT INFORMATION
CREATE TABLE [dbo].[Flights](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[DateFrom] [datetime] NOT NULL,
	[TimeFrom] [varchar](10) NOT NULL,
	[DateTo] [datetime] NOT NULL,
	[TimeTo] [varchar](10) NOT NULL,
	[CityFrom] [varchar](50) NOT NULL,
	[CityTo] [varchar](50) NOT NULL,
	[Airline_id] [int] NOT NULL,
	[Price] [float] NOT NULL,
	[PriceChildren] [float] NOT NULL,
	[Adults] [int] NOT NULL,
	[Children] [int] NOT NULL,
 CONSTRAINT [PK_Flights] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

--CREATING THE DICTIONARY TABLE WITH AIRLINES
CREATE TABLE [dbo].[Airlines](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Name] [varchar](50) NOT NULL,
	[DisplayName] [varchar](50) NOT NULL,
 CONSTRAINT [PK_Airlines] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

--FILLING THE AIRLINES TABLE WITH DATA
INSERT INTO [Flights].[dbo].[Airlines]
           ([Name]
           ,[DisplayName])
     VALUES
           ('Ryanair', 'Ryanair')
INSERT INTO [Flights].[dbo].[Airlines]
           ([Name]
           ,[DisplayName])
     VALUES
           ('KLM', 'KLM')
INSERT INTO [Flights].[dbo].[Airlines]
           ([Name]
           ,[DisplayName])
     VALUES
           ('LOT', 'LOT')
INSERT INTO [Flights].[dbo].[Airlines]
           ([Name]
           ,[DisplayName])
     VALUES
           ('Lufthansa', 'Lufthansa')
INSERT INTO [Flights].[dbo].[Airlines]
           ([Name]
           ,[DisplayName])
     VALUES
           ('British Airways', 'British Airways')
INSERT INTO [Flights].[dbo].[Airlines]
           ([Name]
           ,[DisplayName])
     VALUES
           ('Transavia France', 'Transavia France')
INSERT INTO [Flights].[dbo].[Airlines]
           ([Name]
           ,[DisplayName])
     VALUES
           ('Air Europa', 'Air Europa')

--ADDING A FOREIGN KEY
ALTER TABLE [dbo].[Flights]  WITH CHECK ADD  CONSTRAINT [FK_Flights_Airlines] FOREIGN KEY([Airline_id])
REFERENCES [dbo].[Airlines] ([Id])